package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class UserIntegralConsumeBackRequest extends Request {

	private static final long serialVersionUID = -2693606130203316573L;
	/**
	 * 用户Id
	 */
	private Integer userId;
	/**
	 * 订单Id
	 */
	private String orderId;
	
	public String getOrderId() {
		return orderId;
	}
	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), -1);
		this.orderId = requestInfo.getParameter(ApiUrlParamEnum.orderId.getParamName());
		
		if( userId < 0) {
			throw new RequestIllegalException("用户ID不能为空");
		}
		if(StringUtil.isEmpty(orderId)) {
			throw new RequestIllegalException("订单号不能为空");
		}
		
	}

}
